package com.aeroyun.macross;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * SpringBoot方式启动类
 *
 * @author aeroyun
 * @Date 2017/5/21 12:06
 */
@SpringBootApplication
public class MacrossApplication {

    private final static Logger logger = LoggerFactory.getLogger(MacrossApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(MacrossApplication.class, args);
        logger.info("MacrossApplication is success!");
    }
    
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**").allowedOrigins("*"); 
            }
        };
    }
}
